package com.singbon.server.controller;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.security.oauth2.provider.endpoint.FrameworkEndpoint;
import org.springframework.security.oauth2.provider.token.ConsumerTokenServices;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/**
 */
@Slf4j
@FrameworkEndpoint
public class RevokeTokenEndpoint {

  @Autowired
  @Qualifier("consumerTokenServices")
  ConsumerTokenServices consumerTokenServices;

  @DeleteMapping("/oauth/token")
  @ResponseBody
  public String revokeToken(String access_token) {
    log.info("zzzzzzzzz:{}",access_token);
    if (consumerTokenServices.revokeToken(access_token)){
      return "注销成功";
    }else{
      return "注销失败";
    }
  }
}
